<?php 
$conn = mysqli_connect('127.0.0.1','root','123456','zhiwen');
mysqli_query($conn,'SET NAMES UTF8');
$sql = 'SELECT * FROM books_category as bc left join books as b on bc.bid=b.id left join category as c on bc.cid=c.id WHERE c.id=1 order by b.sales desc limit 0,3';
$sql1 = 'SELECT * FROM books_category as bc left join books as b on bc.bid=b.id left join category as c on bc.cid=c.id WHERE c.id=2 order by b.sales desc limit 0,3';
$sql2 = 'SELECT * FROM books_category as bc left join books as b on bc.bid=b.id left join category as c on bc.cid=c.id WHERE c.id=3 order by b.sales desc limit 0,3';
$result = mysqli_query($conn,$sql);
$result1 = mysqli_query($conn,$sql1);
$result2 = mysqli_query($conn,$sql2);

$books = [];
$books1 = [];
$books2 = [];
while ($row = mysqli_fetch_array($result)) {
   array_push($books,$row);
}
while ($row = mysqli_fetch_array($result1)) {
   array_push($books1,$row);
}
while ($row = mysqli_fetch_array($result2)) {
   array_push($books2,$row);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>知文知著</title>
    <link rel="stylesheet" href="../css/Comment.css">
    <link rel="stylesheet" href="../css/jquery.fullPage.css">
    <link rel="stylesheet" href="../css/literature.css">
    <link rel="stylesheet" href="../css/bottom.css">
    <script src="../js/jquery-3.1.1.js"></script>
    <script src="../js/jquery.fullPage.js"></script>
    <script src="../js/literature.js"></script>
</head>
<body>
    <header></header>
    <!--正文-->
    <div id="fullpage">
        <div class="section">
        <ul class="list" id="list0">
            <?php foreach ($books as  $zhiwen) {?>
                <li><div class="list-left" ><img src="<?php echo($zhiwen['img']) ?>" alt=""></div> <div class="list-right"><p>作者: <?php echo($zhiwen['author']) ?></p>
                <p>书名:<?php echo($zhiwen['bname']) ?></p> <p>简介:<?php echo($zhiwen['introduction']) ?></p> <p> 片段阅读:<?php echo($zhiwen['snippet']) ?> </p>
                <button class="list-btn"><a href="<?php echo($zhiwen['link']) ?>">阅读全文</a></button> </div></li>
             <?php  }?> 
              </ul> 
        </div>
        <div class="section">
            <ul class="list" id="list1">
           <?php foreach ($books1 as  $zhiwen) {?>
                <li><div class="list-left" ><img src="<?php echo($zhiwen['img']) ?>" alt=""></div> <div class="list-right"><p>作者: <?php echo($zhiwen['author']) ?></p>
                <p>书名:<?php echo($zhiwen['bname']) ?></p> <p>简介:<?php echo($zhiwen['introduction']) ?></p> <p> 片段阅读:<?php echo($zhiwen['snippet']) ?> </p>
                <button class="list-btn"><a href="<?php echo($zhiwen['link']) ?>">阅读全文</a></button> </div></li>
             <?php  }?> 
            </ul>
        </div>
        <div class="section">
            <ul class="list" id="list2">
            <?php foreach ($books2 as  $zhiwen) {?>
             <li><div class="list-left" ><img src="<?php echo($zhiwen['img']) ?>" alt=""></div> <div class="list-right"><p>作者: <?php echo($zhiwen['author']) ?></p>
             <p>书名:<?php echo($zhiwen['bname']) ?></p> <p>简介:<?php echo($zhiwen['introduction']) ?></p> <p> 片段阅读:<?php echo($zhiwen['snippet']) ?> </p>
             <button class="list-btn"><a href="<?php echo($zhiwen['link']) ?>">阅读全文</a></button> </div></li>
             <?php  }?> 
            </ul>
        </div>
    </div>
       <div id="Bottom_bottom">

    </div>
</body>
</html>